package com.fmdj.dr.service.impl;
import cn.hutool.core.map.MapUtil;
import cn.hutool.json.JSONUtil;
import com.fmdj.dr.db.dao.DriverSettingsDao;
import com.fmdj.dr.service.DriverSettingsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;


@Service
@Slf4j
public class DriverSettingsServiceImpl implements DriverSettingsService {
    @Resource
    private DriverSettingsDao driverSettingsDao;

    @Override
    public HashMap selectDriverSettings(long driverId) {
        String settings = driverSettingsDao.selectDriverSettings(driverId);
        HashMap hashMap = JSONUtil.parseObj(settings).toBean(HashMap.class);
        boolean listenService = MapUtil.getInt(hashMap, "listenService") == 1;
        boolean autoAccept = MapUtil.getInt(hashMap, "autoAccept") == 1;
        hashMap.replace("listenService", listenService);
        hashMap.replace("autoAccept", autoAccept);
        return hashMap;



    }
}
